import jwt from 'jsonwebtoken'

/**token校验 */
export const vertifyToken = (req,res,next)=>{
     const header =  req.headers.authorization
     const token = header ? header.replace('Bearer ','') : 'Bearer '
      jwt.verify(token,process.env.SecretKey,(err,decode)=>{
           if(err) return res.status(401).send({ msg:'请求失败',code:401,data:{ message:'登录超时' } })
           const { id } = decode
           req.userId = id
           next()
      })
}